<?php 

namespace Common\Common;

/**
* 分类树类
*/
class Tree  
{
	private $temp =array();
	public  function index($data,$fid=0,$cn='├&nbsp;',$fname='顶级分类')
	{

		foreach ($data as $value) {
			if($value['fid']==$fid){
				$value['fname'] = ltrim(trim($fname,'&nbsp;'),'├');
				$fanma = $value['cname'];			
				$value['cname'] = $cn.$value['cname'];
				$this->temp[]=$value;
				$this->index($data,$value['id'],"&nbsp;&nbsp;&nbsp;".$cn, $value['cname']);
			}
		}

		return $this->temp;
	}
}


 ?>